/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package rekeningrijden;

import java.awt.Rectangle;
import util.Sniffer;
import util.SnifferListener;
import javax.swing.JEditorPane;
import javax.swing.JFrame;
import javax.swing.JScrollPane;
import javax.swing.JTextField;
import javax.swing.border.CompoundBorder;

/**
 *
 * @author jonas
 */
public class SnifferGUI extends JFrame implements SnifferListener {
    JEditorPane output = new JEditorPane();
    JScrollPane pane = new JScrollPane(output);
    Sniffer sniffy;

    public SnifferGUI(Sniffer sniffy) {
        output.setAlignmentY(JTextField.TOP_ALIGNMENT);
        output.setEditable(false);
        output.setBorder(new CompoundBorder());
        output.setContentType("text/html");
        this.sniffy = sniffy;
        sniffy.addListener(this);
    }

    public void outputChanged(String newOutput) {
        output.setText("<html> "+newOutput+"</html>");
    }

    public void createAndShowGUI(){
        this.setTitle("Sniffer");
        this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        this.setLocation(500, 0);
        this.getContentPane().add(pane);

        this.setSize(500,400);
        this.setVisible(true);
    }
}
